package com.xyzwps.webfluxjava.handler.demo;

import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;
import org.springframework.web.reactive.function.server.HandlerFunction;
import org.springframework.web.reactive.function.server.ServerRequest;
import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;

@Component
@Slf4j
public class DemoFilters {

    public Mono<ServerResponse> filter1(ServerRequest request, HandlerFunction<ServerResponse> next) {
        log.info("filter1 at {}", request.path());
        request.attributes().put("filter1", "filter1");
        return next.handle(request);
    }

    public Mono<ServerResponse> filter2(ServerRequest request, HandlerFunction<ServerResponse> next) {
        log.info("filter2 at {}", request.path());
        request.attributes().put("filter2", "filter2");
        return next.handle(request);
    }
}
